local GuildWarFightReportInfoCell = app.mvc.createListViewCell(...)
--data =
function GuildWarFightReportInfoCell.create(node)
    local sprite = GuildWarFightReportInfoCell.extend(node or cc.CSLoader:createNode(Res.CSGuildWarFightReportInfoCell))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init()
    return sprite
end


function GuildWarFightReportInfoCell:init(data)
    self.super.init(self, data)
    self:setContentSize( self._ui.Panel:getContentSize() )
    self:refresh()

end

function GuildWarFightReportInfoCell:refresh()
    if not self._data then
        return
    end
    local battleInfo = self._data.data
    if battleInfo then
        local isEmpty = false

        local leader1 = battleInfo:getLeader1()
        if leader1 then
            self._ui["Panel/Panel_data_1/guild"]:setString(string.format(L("WGWTeamName"), leader1))
            self._ui["Panel/Panel_data_1/num"]:setString(battleInfo:getPower1())
        else
            self._ui["Panel/Panel_data_1/guild"]:setString("")
            self._ui["Panel/Panel_data_1/num"]:setString("")
            isEmpty = true
        end

        local leader2 = battleInfo:getLeader2()
        if leader2 then
            self._ui["Panel/Panel_data_2/guild"]:setString(string.format(L("WGWTeamName"), leader2))
            self._ui["Panel/Panel_data_2/num"]:setString(battleInfo:getPower2())
        else
            self._ui["Panel/Panel_data_2/guild"]:setString("")
            self._ui["Panel/Panel_data_2/num"]:setString("")
            isEmpty = true
        end

        if isEmpty then
            self._ui["Panel/bg"]:loadTexture(Res.CSGuildWarGuildReportBg3, 1)
            self._ui["Panel/bg"]:setCapInsets(cc.rect(110,15,13,16))
            self._ui["Panel/text1"]:setString(L("CSGuildWarBattleEmpty2"))
            self._ui["Panel/bg/bg1"]:setVisible(false)
            self._ui["Panel/num_1"]:setString("")
            self._ui["Panel/num_2"]:setString("")
        else
            self._ui["Panel/bg/bg1"]:setVisible(true)
            local score1 = battleInfo:getScore1()
            local score2 = battleInfo:getScore2()
            self._ui["Panel/text1"]:setString(":")
            self._ui["Panel/num_1"]:setString(score1)
            self._ui["Panel/num_2"]:setString(score2)
            if score1 > score2 then
                self._ui["Panel/bg"]:loadTexture(Res.CSGuildWarGuildReportBg1, 1)
                self._ui["Panel/bg"]:setCapInsets(cc.rect(110,15,13,16))
            elseif score1 < score2 then
                self._ui["Panel/bg"]:loadTexture(Res.CSGuildWarGuildReportBg2, 1)
                self._ui["Panel/bg"]:setCapInsets(cc.rect(110,15,13,16))
            else
                self._ui["Panel/bg"]:loadTexture(Res.CSGuildWarGuildReportBg3, 1)
                self._ui["Panel/bg"]:setCapInsets(cc.rect(110,15,13,16))
            end    
        end
    end
    
end








return GuildWarFightReportInfoCell